|
|
|
|
|
|
|
An interesting thing about the Sierpinski gasket is that there are several other very different ways you can create figures that look almost the same. Figure 10.27 shows the first six levels of a curve that looks like the Sierpinski gasket. |
|
|
|
|
|
|
|
|
The remarkably simple curve-drawing subroutine that follows takes as parameters the angle at which it should draw, the distance it must cover, and the amount it should initially turn if it needs to call itself recursively. |
|
|
|
 |
|
|
|
|
' Draw a gasket-like Sierpinski curve. Private Sub SierpinskiGasketCurve(ByVal depth As Integer, _
ByVal theta As Single, ByVal dist As Single, _
ByVal turn As Single)
If depth > 0 Then
SierpinskiGasketCurve depth - 1, _
theta + turn, dist / 2, -turn
SierpinskiGasketCurve depth - 1, _
theta, dist / 2, turn
SierpinskiGasketCurve depth - 1, _
theta - turn, dist / 2, -turn
Else
picCanvas.Line - _
Step(dist * Cos(theta), dist * Sin(theta))
End If
End Sub |
|
|
|
|
|
|
|
|
Figure 10.27
Six levels of a curve that approximates a Sierpinski gasket. |
|
|
|
|
|